package com.woniuxy.sale.entity.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 选货单总表;
 * </p>
 *
 * @author lio
 * @since 2023-09-07
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain=true)
public class SaleAddOrderVo implements Serializable {

    /**
     * 选货单总表id
     */
    private Integer id;

    /**
     * 选货单单号
     */
    private String sno;

    /**
     * 仓库
     */
    private Integer depotId;

    /**
     * 制单人
     */
    private String creator;

    /**
     * 客户
     */
    private String customer;

    /**
     * 制单时间
     */
    private String createTime;

    /**
     * 总价
     */
    private BigDecimal totalPrice;

    /**
     * 状态(0新建，1已提交)
     */
    private String state;


    private List<SaleAddOrderItemVo> orderItemVoList;

    public SaleAddOrderVo(String sno, Integer depotId, String creator, String customer, BigDecimal totalPrice, List<SaleAddOrderItemVo> orderItemVoList) {
        this.sno = sno;
        this.depotId = depotId;
        this.creator = creator;
        this.customer = customer;
        this.totalPrice = totalPrice;
        this.orderItemVoList = orderItemVoList;
    }

    //setId在SQL语句执行成功以后返回当前行id时触发
    private void setId(Integer id){
        System.out.println("setId");
        this.id = id;
        //通知观察者
        for (SaleAddOrderItemVo orderItem : orderItemVoList) {
            orderItem.setSid(id);
        }
    }
}
